extends Resource
class_name BalanceConfig

# Economy Balance
const STARTING_GOLD = 10
const BASE_INCOME = 5
const INTEREST_RATE = 0.1
const MAX_INTEREST = 5
const REFRESH_COST = 2
const EXPERIENCE_COST = 4

# Unit Balance Multipliers
const HEALTH_SCALING = 1.0
const DAMAGE_SCALING = 1.0
const ATTACK_SPEED_SCALING = 1.0

# Synergy Balance
const SYNERGY_MULTIPLIERS = {
	"Tank": {
		"armor_bonus": [15, 30],
		"thresholds": [2, 4]
	},
	"Fighter": {
		"damage_bonus": [10, 20, 35],
		"thresholds": [2, 4, 6]
	},
	"Ranged": {
		"attack_speed_bonus": [0.25, 0.5],
		"thresholds": [2, 3]
	},
	"Mage": {
		"ability_power_bonus": [20, 40, 75],
		"thresholds": [2, 3, 4]
	},
	"Assassin": {
		"crit_chance_bonus": [25, 50],
		"thresholds": [2, 4]
	}
}

# Round Timing
const PREPARATION_TIME = 30.0
const MAX_BATTLE_TIME = 60.0
const ROUND_TRANSITION_TIME = 2.0

# AI Difficulty Settings
const AI_DIFFICULTY_PRESETS = {
	"easy": {
		"decision_quality": 0.3,
		"gold_bonus": 0,
		"reaction_time": 1.0
	},
	"medium": {
		"decision_quality": 0.6,
		"gold_bonus": 2,
		"reaction_time": 0.5
	},
	"hard": {
		"decision_quality": 0.9,
		"gold_bonus": 5,
		"reaction_time": 0.2
	}
}

# Unit Tier Distribution (probability by player level)
const TIER_DISTRIBUTION = [
	[100, 0, 0, 0, 0],    # Level 1
	[80, 20, 0, 0, 0],    # Level 2
	[60, 35, 5, 0, 0],    # Level 3
	[40, 40, 18, 2, 0],   # Level 4
	[25, 40, 30, 5, 0],   # Level 5
	[20, 35, 35, 10, 0],  # Level 6
	[15, 30, 35, 18, 2],  # Level 7
	[10, 25, 35, 25, 5],  # Level 8
	[5, 20, 35, 30, 10]   # Level 9
]

# Combat Balance
const CRITICAL_DAMAGE_MULTIPLIER = 2.0
const MANA_PER_ATTACK = 10.0
const MAX_MANA = 100.0
const STUN_DAMAGE_REDUCTION = 0.5

# Visual Settings
const DAMAGE_NUMBER_DURATION = 1.0
const HEALTH_BAR_HEIGHT = 2.5
const PARTICLE_LIFETIME = 0.5

# Get balanced unit stats
static func get_balanced_unit_stats(tier: int) -> Dictionary:
	var base_stats = {
		1: {"health": 100, "damage": 20, "speed": 5},
		2: {"health": 150, "damage": 30, "speed": 5},
		3: {"health": 200, "damage": 40, "speed": 5},
		4: {"health": 300, "damage": 60, "speed": 5},
		5: {"health": 500, "damage": 100, "speed": 5}
	}
	
	var stats = base_stats.get(tier, base_stats[1])
	stats.health *= HEALTH_SCALING
	stats.damage *= DAMAGE_SCALING
	
	return stats

# Get shop probabilities based on level
static func get_shop_probabilities(level: int) -> Array:
	if level <= 0 or level > TIER_DISTRIBUTION.size():
		return TIER_DISTRIBUTION[0]
	return TIER_DISTRIBUTION[level - 1]

# Calculate interest
static func calculate_interest(gold: int) -> int:
	return min(int(gold * INTEREST_RATE), MAX_INTEREST)

# Get streak bonus
static func get_streak_bonus(streak: int, is_win_streak: bool) -> int:
	if is_win_streak:
		return min(streak, 3)
	else:
		return min(streak * 2, 6)